package com.catal.framework.log.dao;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.catal.framework.dao.impl.JdbcDaoImpl;

/**
 * SYS_OPER_LOG操作记录 DAO
 * 
 *
 */
public class OperLogDao extends JdbcDaoImpl{
	
	/**
	 * 日志
	 */
	private static Log log = LogFactory.getLog(OperLogDao.class);
	
	/**
	 * 
	 * @param operUser 操作用户
	 * @param authUser 授权用户
	 * @param operIP 操作用户ip
	 * @param operType 操作类型
	 * @param operObject 操作对象
	 * @param operDesc 操作描述
	 * @return
	 */
	public boolean insert(String operUser,String authUser,String operIP,String operType,String operObject,String operDesc){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("log_date", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()));
		map.put("oper_user", operUser);
		map.put("auth_user", authUser);
		map.put("oper_ip", operIP);
		map.put("oper_type", operType);
		map.put("oper_obj", operObject);
		map.put("oper_desc", operDesc);
		
		try{
			super.insertRecord(map);
			return true;
		}catch (Exception e) {
			log.error(String.format("登记操作记录%s失败",map),e);
			return false;
		}
	}
	
	/**
	 * 新增
	 * @param authUser 授权用户
	 * @param operType 操作类型
	 * @param operObject 操作对象
	 * @param operDesc 操作描述
	 * @return
	 */
	public boolean insert(String authUser,String operType,String operObject,String operDesc){
		//return insert(SecurityUtils.getLoginId(), authUser, SecurityUtils.getLoginIp(), operType, operObject, operDesc);
		return false;
	}
}